package com.neucloud.da.edgeside.controller;

import com.neucloud.da.edgeside.business.IsvcOnlineBusiness;
import com.neucloud.da.edgeside.model.constant.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping()
public class IsvcOnlineController {

    @Autowired
    IsvcOnlineBusiness isvcOnlineBusiness;

    @PostMapping("/v302/isvc/online")
    public Result createIsvcOnline(@RequestParam("version") String version,
                                   @RequestBody MultipartFile file){
        return Result.succeed(isvcOnlineBusiness.createIsvcOnline(version,file));
    }

    @GetMapping("v302/isvc/online/status")
    public Result getArgFileContent(@RequestParam("isvcOnlineId") String isvcOnlineId){
        return Result.succeed(isvcOnlineBusiness.getIsvcOnlineStatus(isvcOnlineId));
    }

    @RequestMapping("v302/isvc/online/req/{isvcOnlineId}")
    public ResponseEntity reqOnlineService(@PathVariable String isvcOnlineId){
        return isvcOnlineBusiness.onlineApi(isvcOnlineId);
    }

    @GetMapping("v302/isvc/online/stop")
    public Result stopOnline(@RequestParam("isvcOnlineId") String isvcOnlineId){
        return Result.succeed(isvcOnlineBusiness.stopOnline(isvcOnlineId));
    }

    @DeleteMapping("v302/isvc/online")
    public Result delOnline(@RequestParam("isvcOnlineId") String isvcOnlineId){
        return Result.succeed(isvcOnlineBusiness.delOnline(isvcOnlineId));
    }

}
